﻿using System;
using System.Windows.Input;

namespace TestApp
{
    public class Command : ICommand
    {
        private readonly Action _theaction;

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public void Execute(object parameter)
        {
            _theaction();
        }

        public Command(Action action)
        {
            _theaction = action;
        }

        public event EventHandler CanExecuteChanged;
    }

    public class Command<T> : ICommand
    {
        private readonly Action<T> _theaction;

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public void Execute(object parameter)
        {
            _theaction((T)parameter);
        }

        public Command(Action<T> action)
        {
            _theaction = action;
        }

        public event EventHandler CanExecuteChanged;
    }
}
